#ifndef CONNECTIONTHREAD
#define CONNECTIONTHREAD

#include <app\session.h>
#include <commands\command.h>
#include <commands\commandFactory.h>

#include <Poco/Net/SocketAddress.h>
#include <Poco/Net/StreamSocket.h>
#include <Poco/Net/SocketStream.h>
#include <Poco/Exception.h> 
#include <Poco/Thread.h>
#include <Poco/Runnable.h>

#include <iostream>
#include <vector>

using Poco::Net::SocketAddress; 
using Poco::Net::StreamSocket; 
using Poco::Net::SocketStream;
using Poco::Exception;
using Poco::Mutex;

class connectionThread: public Poco::Runnable {

  void receiveBytes(void *buffer, StreamSocket &socket, unsigned int count);

private:

  Poco::Mutex commands_mutex;
  vector<command *> commands;

  virtual void run();

public:
  
  streaming::session state;

  void addCommand(command *cmd);

  ~connectionThread();
};

#endif